import shapefile
import utm

r = shapefile.Reader("shapefiles/NYC_MUSEUMS/NYC_MUSEUMS_GEO")


w = shapefile.Writer("shapefiles/NYC_MUSEUMS/NYC_MUSEUMS_UTM", shapeType=1)

# 1.复制字段
w.fields = list(r.fields[1:])

# 2.复制记录（属性）
print(type(r.iterShapeRecords()))
for itme in r.iterShapeRecords():
    w.record(*itme.record)
# w.record('Alexander Hamilton U.S. Custom House', '(212) 514-3700',
# 'http://www.oldnycustomhouse.gov/', '1 Bowling Grn', '', 'New York', 10004.0)

# 3. 复制图形信息
for s in r.iterShapes():
    lon, lat = s.points[0]  # r.shapes()[0].points[0]
    y, x, zone, band = utm.from_latlon(lat, lon)
    w.point(x, y)

# 4.关闭
r.close()
w.close()



